package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.business.Ad;
import com.qingcheng.service.business.AdService;
import com.qingcheng.service.goods.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

/**
 * Created by yuanxin
 * Date:2019/7/2
 * Time:14:29
 */
@Controller
public class IndexController {
    @Reference
    private AdService adService;
    @Reference
    private CategoryService categoryService;

    /**加载主页
     * @param model
     * @return
     */
    @GetMapping("/index")
    public String index(Model model){
        List<Ad> lbtList = adService.findByPosition("web_index_lb");
        model.addAttribute("lbt",lbtList);
        List<Map>  categoryList= categoryService.findCategoryTree();
        System.out.println(categoryList);
        model.addAttribute("categoryList",categoryList);
        return "index";
    }
}
